#ifndef SETTINGPAGE_H
#define SETTINGPAGE_H
#include <QWidget>
#include "setting.h"
#include "titlebar.h"
#include "settingpagetitle.h"
#include <QGSettings>

class SettingPage:public QWidget
{
        Q_OBJECT
public:
    SettingPage(QPoint *p):pos(p){}
    //SettingPage();
    SettingPage(QWidget *parent = nullptr);
    ~SettingPage();

    QString nowThemeStyle;  //lhl debug
    static QGSettings *m_pGsettingThemeData; //lhl debug
    QString current_dir;
    QString current_photoFormat;
    QString current_videoFormat;
    QLabel *current_dir_lab;
    QLabel *current_cameraDev;
    QLabel *current_videoDev;
    QLabel *current_savePhotoFormat; //lhl debug
    QLabel *current_savevideoFormat;
    QLabel *current_scale;

    static QSettings *resolution_setting;
    void init_ui();
    void Geometry(QPoint *);
signals:
    void dir_change();
    void change_dev(const char *);
    void change_resolutions(QPair<uint,uint>);
  //  void scale_change();

public slots:
    void dir_click();
    void change_item();
    void change_cameraDevice(const char *);
    void close();
    void confirm_click();
    void cancel_click();
    void update();
  //  void scale_click();
  //  void cameraDevice_click();
  //  void videoDevice_click();
  //  void delay_click();
  //  void mirror_click();
    protected:
        void mouseMoveEvent(QMouseEvent *);
        void mousePressEvent(QMouseEvent *);
        void mouseReleaseEvent(QMouseEvent *);
    private:
        QLabel *titleLab;
        QLabel *dirlab;
        QLabel *browselab;
        QLabel *scalelab;
        QLabel *cameraDevicelab;
        QLabel *videoDevicelab;
        QLabel *savePhotoFormatlab;
        QLabel *savevideoFormatlab;
        //功能按钮部分
        //QComboBox *dir;
        QLineEdit *dir;
        QPushButton *browse;
        QComboBox *scale;
        QComboBox *cameraDevice;
        QComboBox *videoDevice;
        QComboBox *savePhotoFormat;
        QComboBox *savevideoFormat;
        SwitchButton *delaybtn;
        SwitchButton *mirrorbtn;
        QPushButton *confirm;
        QPushButton *cancel;

        QVBoxLayout *vlayout;
        QHBoxLayout *btnLayout;
        QHBoxLayout *dirLayout;
        QHBoxLayout *titleLayout;
        QHBoxLayout *scaleLayout;
        QHBoxLayout *cameraDeviceLayout;
        QHBoxLayout *videoDeviceLayout;
        QHBoxLayout *savePhotoFormatLayout;
        QHBoxLayout *savevideoFormatLayout;

        QWidget *dirLayoutWidget;
        QWidget *scaleLayoutWidget;
        QWidget *cameraDeviceLayoutWidget;
        QWidget *savePhotoFormatLayoutWidget;
        QWidget *savevideoFormatLayoutWidget;

        QPoint *pos;
        QPoint m_start;
        QMap<QString,QString> camera_name2dev;
        QMap<QString,QString> audio_name2dev;
        QString scale_str;
        QString first;
        SettingPageTitle *settingPageTitle = nullptr;  //lhl add
        QVBoxLayout *settingTitleLayout = new QVBoxLayout;
        static int dev_change;
        static bool press;
        void dealSystemGsettingChange(const QString);
        void refreshThemeBySystemConf();
    };

    #endif // SETTINGPAGE_H
